package com.crpc.core;

import com.crpc.core.channelHandler.ConsumerChannelInitializer;
import io.netty.bootstrap.Bootstrap;
import io.netty.channel.nio.NioEventLoopGroup;
import io.netty.channel.socket.nio.NioSocketChannel;
import lombok.Data;
import lombok.Getter;
import lombok.extern.slf4j.Slf4j;

/**
 * @author CLOUD
 * @version 1.0
 * @description:
 * @date 2023/9/10 9:32
 */
@Slf4j
@Data
public class NettyBootstrapInitializer {

    // 创建Bootstrap对象
    @Getter
    private static Bootstrap bootstrap = new Bootstrap();

    // 静态块，初始化Bootstrap
    static {
        // 创建一个NioEventLoopGroup
        NioEventLoopGroup group = new NioEventLoopGroup();
        // 配置Bootstrap
        bootstrap.group(group)
                // 使用NioSocketChannel作为通道
                .channel(NioSocketChannel.class)
                // 添加ConsumerChannelInitializer处理器
                .handler(new ConsumerChannelInitializer());
    }

    // 构造方法
    private NettyBootstrapInitializer() {
    }


}
